package com.oocl.euc.core.maintenance.service;

import com.oocl.euc.core.maintenance.model.Users;
import com.oocl.euc.core.maintenance.repository.UsersRepository;
import com.oocl.euc.framework.base.persistence.IBaseRepository;
import com.oocl.euc.framework.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UsersService extends BaseService<Users, String> {
    @Autowired
    UsersRepository usersRepository;

    @Override
    protected IBaseRepository<Users, String> getRepository() {
        return usersRepository;
    }

    public Users insertTempUser(Users tempUser) {
        tempUser.setNeedSync(false);
        return save(tempUser);
    }

    public List<Users> getTempUsers() {
        return usersRepository.getTempUsers();
    }

    public List<String> getUserDepartments() {
        return usersRepository.getUserDepartments();
    }

    @Cacheable(cacheNames = "cusCache")
    public Users findByDomainId(String domainId) {
        return usersRepository.findByDomainId(domainId);
    }
}
